﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Administrator
{
    public class cFileBin
    {
        //Загрузка струтуры дерева сети из файла
        public static Boolean LoadNetworkFromFile(String FilePath)
        {
            Boolean Result = false;
            StreamReader SReader = null;
            Int32 Count = 0;
            Int32 i, j, k, l;
            String SettingStr = "";

            //Загрузка параметров конфигурации из файла           
            if (File.Exists(FilePath))
            {
                try { SReader = File.OpenText(FilePath); }
                catch { SReader = null; }
            }
            if (SReader != null)
            {
                try
                {
                    cMain.ResetNetwork();
                    //Загрузка списка типов устройств для справочника
                    Count = Int32.Parse(SReader.ReadLine());
                    cMain.DevTypeList = new cMain.DEVTYPE_SETTING[Count];
                    for (i = 0; i < cMain.DevTypeList.Length; i++)
                    {
                        cMain.DevTypeList[i].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                        cMain.DevTypeList[i].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                        cMain.DevTypeList[i].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                        cMain.DevTypeList[i].ID = Int32.Parse(SReader.ReadLine());
                        cMain.DevTypeList[i].DeviceDllName = SReader.ReadLine();
                        cMain.DevTypeList[i].ProtocolDLLName = SReader.ReadLine();
                        cMain.DevTypeList[i].Caption = SReader.ReadLine();
                        cMain.DevTypeList[i].DeviceKind = Byte.Parse(SReader.ReadLine());
                        cMain.DevTypeList[i].ChannelCount = Int32.Parse(SReader.ReadLine());
                        cMain.DevTypeList[i].FileCodeNPATS = SReader.ReadLine();
                        cMain.DevTypeList[i].ProtocolSetting = new Byte[Int32.Parse(SReader.ReadLine())];
                        SettingStr = SReader.ReadLine();
                        for (j = 0; j < cMain.DevTypeList[i].ProtocolSetting.Length; j++)
                        {
                            cMain.DevTypeList[i].ProtocolSetting[j] = Byte.Parse(SettingStr.Substring(0, SettingStr.IndexOf("|")));
                            SettingStr = SettingStr.Substring(SettingStr.IndexOf("|") + 1, SettingStr.Length - SettingStr.IndexOf("|") - 1);
                        }
                    }                    
                    //Загрузка списка типов счетчиков для справочника
                    Count = Int32.Parse(SReader.ReadLine());
                    cMain.MeterList = new cMain.METER_SETTING[Count];
                    for (i = 0; i < cMain.MeterList.Length; i++)
                    {
                        cMain.MeterList[i].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                        cMain.MeterList[i].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                        cMain.MeterList[i].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                        cMain.MeterList[i].ID = Int32.Parse(SReader.ReadLine());
                        cMain.MeterList[i].Caption = SReader.ReadLine();
                        cMain.MeterList[i].Precision = Double.Parse(SReader.ReadLine());
                        cMain.MeterList[i].BeforeComma = Byte.Parse(SReader.ReadLine());
                        cMain.MeterList[i].AfterComma = Byte.Parse(SReader.ReadLine());
                        cMain.MeterList[i].MeterConst = Int32.Parse(SReader.ReadLine());
                        cMain.MeterList[i].Phase = Byte.Parse(SReader.ReadLine());
                        cMain.MeterList[i].SelfDemand = Double.Parse(SReader.ReadLine());
                    }
                    //Загрузка списка типов каналов связи для справочника
                    Count = Int32.Parse(SReader.ReadLine());
                    cMain.CommChanList = new cMain.COMMCHAN_SETTING[Count];
                    for (i = 0; i < cMain.CommChanList.Length; i++)
                    {
                        cMain.CommChanList[i].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                        cMain.CommChanList[i].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                        cMain.CommChanList[i].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                        cMain.CommChanList[i].ID = Int32.Parse(SReader.ReadLine());
                        cMain.CommChanList[i].DllName = SReader.ReadLine();
                        cMain.CommChanList[i].Caption = SReader.ReadLine();
                        cMain.CommChanList[i].GroupID = Byte.Parse(SReader.ReadLine());
                        cMain.CommChanList[i].Setting = new Byte[Int32.Parse(SReader.ReadLine())];
                        SettingStr = SReader.ReadLine();
                        for (j = 0; j < cMain.CommChanList[i].Setting.Length; j++)
                        {
                            cMain.CommChanList[i].Setting[j] = Byte.Parse(SettingStr.Substring(0, SettingStr.IndexOf("|")));
                            SettingStr = SettingStr.Substring(SettingStr.IndexOf("|") + 1, SettingStr.Length - SettingStr.IndexOf("|") - 1);
                        }
                    }
                    //Загрузка списка типов тарифов для справочника
                    Count = Int32.Parse(SReader.ReadLine());
                    cMain.TariffList = new cMain.TARIFF_SETTING[Count];
                    for (i = 0; i < cMain.TariffList.Length; i++)
                    {
                        cMain.TariffList[i].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                        cMain.TariffList[i].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                        cMain.TariffList[i].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                        cMain.TariffList[i].ID = Int32.Parse(SReader.ReadLine());
                        cMain.TariffList[i].Caption = SReader.ReadLine();
                        cMain.TariffList[i].FillColor = Int32.Parse(SReader.ReadLine());
                    }
                    //Загрузка списка прав доступа для пользователей для справочника
                    Count = Int32.Parse(SReader.ReadLine());
                    cMain.AccessList = new cMain.ACCESS_SETTING[Count];
                    for (i = 0; i < cMain.AccessList.Length; i++)
                    {
                        cMain.AccessList[i].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                        cMain.AccessList[i].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                        cMain.AccessList[i].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());                        
                        cMain.AccessList[i].ID = Int32.Parse(SReader.ReadLine());
                        cMain.AccessList[i].Caption = SReader.ReadLine();
                    }
                    //Загрузка списка пользователей для справочника
                    Count = Int32.Parse(SReader.ReadLine());
                    cMain.UserList = new cMain.USER_SETTING[Count];
                    for (i = 0; i < cMain.UserList.Length; i++)
                    {
                        cMain.UserList[i].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                        cMain.UserList[i].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                        cMain.UserList[i].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                        cMain.UserList[i].ID = Int32.Parse(SReader.ReadLine());
                        cMain.UserList[i].Caption = SReader.ReadLine();
                        cMain.UserList[i].Password = SReader.ReadLine();
                        cMain.UserList[i].AccessID = Int32.Parse(SReader.ReadLine());                        
                    }
                    //Загрузка списка типов групп отчетов для присоединений
                    Count = Int32.Parse(SReader.ReadLine());
                    cMain.ReportGroupList = new cMain.REPORT_GROUP_SETTING[Count];
                    for (i = 0; i < cMain.ReportGroupList.Length; i++)
                    {
                        cMain.ReportGroupList[i].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                        cMain.ReportGroupList[i].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                        cMain.ReportGroupList[i].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                        cMain.ReportGroupList[i].ID = Int32.Parse(SReader.ReadLine());
                        cMain.ReportGroupList[i].Caption = SReader.ReadLine();
                    }
                    //Загрузка списка территориальных объединений
                    Count = Int32.Parse(SReader.ReadLine());
                    cMain.DC = new cMain.DC_ITEM[Count];
                    for (i = 0; i < cMain.DC.Length; i++)
                    {
                        cMain.DC[i].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                        cMain.DC[i].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                        cMain.DC[i].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                        cMain.DC[i].ParentID = Int32.Parse(SReader.ReadLine());
                        cMain.DC[i].ID = Int32.Parse(SReader.ReadLine());
                        cMain.DC[i].Caption = SReader.ReadLine();
                    }
                    //Загрузка списка объектов
                    Count = Int32.Parse(SReader.ReadLine());
                    cMain.Objects = new cMain.OBJECT[Count];
                    for (i = 0; i < cMain.Objects.Length; i++)
                    {
                        cMain.Objects[i].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                        cMain.Objects[i].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                        cMain.Objects[i].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                        cMain.Objects[i].DCID = Int32.Parse(SReader.ReadLine());
                        cMain.Objects[i].ID = Int32.Parse(SReader.ReadLine());
                        cMain.Objects[i].Caption = SReader.ReadLine();
                        cMain.Objects[i].ComputerAddress = Int32.Parse(SReader.ReadLine());
                        cMain.Objects[i].CommChan = Int32.Parse(SReader.ReadLine());
                        cMain.Objects[i].AddCommChan = Int32.Parse(SReader.ReadLine());
                        cMain.Objects[i].CollectionState = Boolean.Parse(SReader.ReadLine());
                        cMain.Objects[i].CollectionStartDT = DateTime.Parse(SReader.ReadLine());
                        //Расписание сбора
                        cMain.Objects[i].Schedule = new cMain.SCHEDULE[cConst.SCHEDULE_LENGTH];
                        for (j = 0; j < cMain.Objects[i].Schedule.Length; j++)
                        {
                            cMain.Objects[i].Schedule[j].ID = Int32.Parse(SReader.ReadLine());
                            cMain.Objects[i].Schedule[j].PeriodTypeID = Byte.Parse(SReader.ReadLine());
                            cMain.Objects[i].Schedule[j].PeriodCountID = UInt16.Parse(SReader.ReadLine());
                            cMain.Objects[i].Schedule[j].CollectOn = Boolean.Parse(SReader.ReadLine());
                            cMain.Objects[i].Schedule[j].CPeriodType = Byte.Parse(SReader.ReadLine());
                            cMain.Objects[i].Schedule[j].CPeriodCount = UInt16.Parse(SReader.ReadLine());
                            cMain.Objects[i].Schedule[j].DPeriodType = Byte.Parse(SReader.ReadLine());
                            cMain.Objects[i].Schedule[j].DPeriodCount = UInt16.Parse(SReader.ReadLine());
                            cMain.Objects[i].Schedule[j].HPeriodType = Byte.Parse(SReader.ReadLine());
                            cMain.Objects[i].Schedule[j].HPeriodCount = UInt16.Parse(SReader.ReadLine());
                        }                        
                        cMain.Objects[i].CodeNPATS = SReader.ReadLine();
                        cMain.Objects[i].Code63002 = SReader.ReadLine();
                        cMain.Objects[i].IsExported = Boolean.Parse(SReader.ReadLine());
                        cMain.Objects[i].ExportDCID = Int32.Parse(SReader.ReadLine());
                        cMain.Objects[i].ExportObjID = Int32.Parse(SReader.ReadLine());
                        //Загрузка списка устройств
                        Count = Int32.Parse(SReader.ReadLine());
                        cMain.Objects[i].Device = new cMain.DEVICE[Count];
                        for (j = 0; j < cMain.Objects[i].Device.Length; j++)
                        {
                            cMain.Objects[i].Device[j].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                            cMain.Objects[i].Device[j].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                            cMain.Objects[i].Device[j].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                            cMain.Objects[i].Device[j].ID = Int32.Parse(SReader.ReadLine());
                            cMain.Objects[i].Device[j].DeviceID = Int32.Parse(SReader.ReadLine());
                            cMain.Objects[i].Device[j].NetAddress = Int32.Parse(SReader.ReadLine());
                            cMain.Objects[i].Device[j].Address = Int32.Parse(SReader.ReadLine());
                            cMain.Objects[i].Device[j].Identifier = SReader.ReadLine();
                            cMain.Objects[i].Device[j].SerialNumber = SReader.ReadLine();
                            cMain.Objects[i].Device[j].JournalLastDT = DateTime.Parse(SReader.ReadLine());
                            cMain.Objects[i].Device[j].LastEventIdx = Int32.Parse(SReader.ReadLine());
                            cMain.Objects[i].Device[j].IsExported = Boolean.Parse(SReader.ReadLine());
                            cMain.Objects[i].Device[j].UserName = SReader.ReadLine();
                            cMain.Objects[i].Device[j].UserPassword = SReader.ReadLine();
                            //Настройки протокола обмена
                            Count = Int32.Parse(SReader.ReadLine());
                            cMain.Objects[i].Device[j].ProtocolSetting = new Byte[Count];
                            SettingStr = SReader.ReadLine();
                            for (k = 0; k < cMain.Objects[i].Device[j].ProtocolSetting.Length; k++)
                            {
                                cMain.Objects[i].Device[j].ProtocolSetting[k] = Byte.Parse(SettingStr.Substring(0, SettingStr.IndexOf("|")));
                                SettingStr = SettingStr.Substring(SettingStr.IndexOf("|") + 1, SettingStr.Length - SettingStr.IndexOf("|") - 1);
                            }
                            //Загрузка списка коммутационного оборудования устройства
                            Count = Int32.Parse(SReader.ReadLine());
                            cMain.Objects[i].Device[j].CommEquipment = new cMain.COMMUTATION_EQUIPMENT[Count];
                            for (k = 0; k < cMain.Objects[i].Device[j].CommEquipment.Length; k++)
                            {
                                cMain.Objects[i].Device[j].CommEquipment[k].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                                cMain.Objects[i].Device[j].CommEquipment[k].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].CommEquipment[k].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].CommEquipment[k].ID = Int32.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].CommEquipment[k].ChannelNumber = Int32.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].CommEquipment[k].Caption = SReader.ReadLine();
                            }
                            //Загрузка списка присоединений устройства
                            Count = Int32.Parse(SReader.ReadLine());
                            cMain.Objects[i].Device[j].Join = new cMain.JOIN[Count];
                            for (k = 0; k < cMain.Objects[i].Device[j].Join.Length; k++)
                            {
                                cMain.Objects[i].Device[j].Join[k].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                                cMain.Objects[i].Device[j].Join[k].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].DeviceID = Int32.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].ID = Int32.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].Index = Int32.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].Caption = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].MeterNumber = Int32.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].CollectEnable = Boolean.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].CoeffMultiply = Boolean.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].ConvertParam = Boolean.Parse(SReader.ReadLine());
                                //Загрузка настроек каналов присоединения
                                Count = Int32.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].Channel = new cMain.CHANNEL[Count];
                                for (l = 0; l < cMain.Objects[i].Device[j].Join[k].Channel.Length; l++)
                                {
                                    cMain.Objects[i].Device[j].Join[k].Channel[l].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                                    cMain.Objects[i].Device[j].Join[k].Channel[l].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].Channel[l].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].Channel[l].ID = Int32.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].Channel[l].CollectEnable = Boolean.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].Channel[l].EnergyType = Byte.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].Channel[l].MeterSerial = SReader.ReadLine();
                                    cMain.Objects[i].Device[j].Join[k].Channel[l].MeterID = Int32.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].Channel[l].ExportNPATSCode = SReader.ReadLine();
                                    cMain.Objects[i].Device[j].Join[k].Channel[l].ImportNPATSCode = SReader.ReadLine();
                                    cMain.Objects[i].Device[j].Join[k].Channel[l].Value63002Code = SReader.ReadLine();
                                    cMain.Objects[i].Device[j].Join[k].Channel[l].ASKPIdentifier = SReader.ReadLine();
                                }
                                cMain.Objects[i].Device[j].Join[k].KTT = UInt16.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].KTN = UInt16.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].KTTClass = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].KTNClass = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].IdlingLosts = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].ShortCircuitLosts = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].TransformatorPower = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].MeterLostsValue = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].TTLostsValue = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].TNLostsValue = Double.Parse(SReader.ReadLine());
                                //Линии электропередач (потери)
                                Count = Int32.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].ConnLineLosts = new cMain.CONN_LINE_LOSTS[Count];
                                for (l = 0; l < cMain.Objects[i].Device[j].Join[k].ConnLineLosts.Length; l++)
                                {
                                    cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                                    cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].ID = Int32.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].LineLength = Double.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].Resistance = Double.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].UNominal = Double.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].CableLost = Double.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].AirLost = Double.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].CircuitsAmount = Int32.Parse(SReader.ReadLine());
                                }
                                cMain.Objects[i].Device[j].Join[k].MeterCodeHPATS = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].ExportCodeHPATS = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].ImportCodeHPATS = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].CollectPointAddress = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].MeterPlacement = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].Comments = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].AbonentNumber = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].AgreementNumber = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].EvidenceMetod = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].BalanceBelonging = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].Director = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].GeneralPES = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].PhoneNumber = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].DTLastInspection = DateTime.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].InSubscriberGroup = Boolean.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].KPE = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].KPM = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].UTariffLevel = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].UTransformator = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].TransformatorLosts = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].LineLosts = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].ITransformatorType = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].INominalFirstTT = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].INominalSecondTT = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].UTransformatorType = SReader.ReadLine();
                                cMain.Objects[i].Device[j].Join[k].UNominalFirstTT = Double.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].UNominalSecondTT = Double.Parse(SReader.ReadLine());
                                Count = Int32.Parse(SReader.ReadLine());
                                cMain.Objects[i].Device[j].Join[k].ReportGroup = new cMain.REPORT_GROUP[Count];
                                for (l = 0; l < cMain.Objects[i].Device[j].Join[k].ReportGroup.Length; l++)
                                {
                                    cMain.Objects[i].Device[j].Join[k].ReportGroup[l].ItemAction.DBExist = Boolean.Parse(SReader.ReadLine());//Добавить проверку относительно текущей базы
                                    cMain.Objects[i].Device[j].Join[k].ReportGroup[l].ItemAction.Changed = Boolean.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].ReportGroup[l].ItemAction.Deleted = Boolean.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].ReportGroup[l].ID = Int32.Parse(SReader.ReadLine());
                                    cMain.Objects[i].Device[j].Join[k].ReportGroup[l].RGType = Int32.Parse(SReader.ReadLine());
                                }
                            }
                        }
                    }
                    Result = true;
                }
                catch
                {
                    cMain.ResetNetwork();
                    Result = false;
                }
                SReader.Close();
            }
            return Result;
        }
        //Сохранение струтуры дерева сети в файл
        public static Boolean SaveNetworkToFile(String FilePath)
        {
            Boolean Result = false;
            StreamWriter SWriter;
            Int32 i, j, k, l;
            String SettingStr;

            SWriter = new StreamWriter(FilePath, false, Encoding.Unicode);

            //Сохранение параметров конфигурации в файла           
            if (SWriter != null)
            {
                try
                {
                    //Сохранение списка типов устройств для справочника                    
                    SWriter.WriteLine(cMain.DevTypeList.Length.ToString());
                    for (i = 0; i < cMain.DevTypeList.Length; i++)
                    {
                        SWriter.WriteLine(cMain.DevTypeList[i].ItemAction.DBExist.ToString());
                        SWriter.WriteLine(cMain.DevTypeList[i].ItemAction.Changed.ToString());
                        SWriter.WriteLine(cMain.DevTypeList[i].ItemAction.Deleted.ToString());
                        SWriter.WriteLine(cMain.DevTypeList[i].ID.ToString());
                        SWriter.WriteLine(cMain.DevTypeList[i].DeviceDllName);
                        SWriter.WriteLine(cMain.DevTypeList[i].ProtocolDLLName);
                        SWriter.WriteLine(cMain.DevTypeList[i].Caption);
                        SWriter.WriteLine(cMain.DevTypeList[i].DeviceKind.ToString());
                        SWriter.WriteLine(cMain.DevTypeList[i].ChannelCount.ToString());
                        SWriter.WriteLine(cMain.DevTypeList[i].FileCodeNPATS);
                        SWriter.WriteLine(cMain.DevTypeList[i].ProtocolSetting.Length.ToString());
                        SettingStr = "";
                        for (j = 0; j < cMain.DevTypeList[i].ProtocolSetting.Length; j++)
                            SettingStr = SettingStr + cMain.DevTypeList[i].ProtocolSetting[j].ToString() + "|";
                        SWriter.WriteLine(SettingStr);
                    }                    
                    //Сохранение списка типов счетчиков для справочника                    
                    SWriter.WriteLine(cMain.MeterList.Length.ToString());
                    for (i = 0; i < cMain.MeterList.Length; i++)
                    {
                        SWriter.WriteLine(cMain.MeterList[i].ItemAction.DBExist.ToString());
                        SWriter.WriteLine(cMain.MeterList[i].ItemAction.Changed.ToString());
                        SWriter.WriteLine(cMain.MeterList[i].ItemAction.Deleted.ToString());
                        SWriter.WriteLine(cMain.MeterList[i].ID.ToString());
                        SWriter.WriteLine(cMain.MeterList[i].Caption);
                        SWriter.WriteLine(cMain.MeterList[i].Precision.ToString());
                        SWriter.WriteLine(cMain.MeterList[i].BeforeComma.ToString());
                        SWriter.WriteLine(cMain.MeterList[i].AfterComma.ToString());
                        SWriter.WriteLine(cMain.MeterList[i].MeterConst.ToString());
                        SWriter.WriteLine(cMain.MeterList[i].Phase.ToString());
                        SWriter.WriteLine(cMain.MeterList[i].SelfDemand.ToString());
                    }
                    //Сохранение списка типов каналов связи для справочника                    
                    SWriter.WriteLine(cMain.CommChanList.Length.ToString());
                    for (i = 0; i < cMain.CommChanList.Length; i++)
                    {
                        SWriter.WriteLine(cMain.CommChanList[i].ItemAction.DBExist.ToString());
                        SWriter.WriteLine(cMain.CommChanList[i].ItemAction.Changed.ToString());
                        SWriter.WriteLine(cMain.CommChanList[i].ItemAction.Deleted.ToString());
                        SWriter.WriteLine(cMain.CommChanList[i].ID.ToString());
                        SWriter.WriteLine(cMain.CommChanList[i].DllName);
                        SWriter.WriteLine(cMain.CommChanList[i].Caption);
                        SWriter.WriteLine(cMain.CommChanList[i].GroupID.ToString());
                        SWriter.WriteLine(cMain.CommChanList[i].Setting.Length.ToString());
                        SettingStr = "";
                        for (j = 0; j < cMain.CommChanList[i].Setting.Length; j++)
                            SettingStr = SettingStr + cMain.CommChanList[i].Setting[j].ToString() + "|";
                        SWriter.WriteLine(SettingStr);
                    }
                    //Сохранение списка типов тарифов для справочника                    
                    SWriter.WriteLine(cMain.TariffList.Length.ToString());
                    for (i = 0; i < cMain.TariffList.Length; i++)
                    {
                        SWriter.WriteLine(cMain.TariffList[i].ItemAction.DBExist.ToString());
                        SWriter.WriteLine(cMain.TariffList[i].ItemAction.Changed.ToString());
                        SWriter.WriteLine(cMain.TariffList[i].ItemAction.Deleted.ToString());
                        SWriter.WriteLine(cMain.TariffList[i].ID.ToString());
                        SWriter.WriteLine(cMain.TariffList[i].Caption);
                        SWriter.WriteLine(cMain.TariffList[i].FillColor.ToString());
                    }
                    //Сохранение списка прав доступа для пользователей для справочника
                    SWriter.WriteLine(cMain.AccessList.Length.ToString());
                    for (i = 0; i < cMain.AccessList.Length; i++)
                    {
                        SWriter.WriteLine(cMain.AccessList[i].ItemAction.DBExist.ToString());
                        SWriter.WriteLine(cMain.AccessList[i].ItemAction.Changed.ToString());
                        SWriter.WriteLine(cMain.AccessList[i].ItemAction.Deleted.ToString());
                        SWriter.WriteLine(cMain.AccessList[i].ID.ToString());
                        SWriter.WriteLine(cMain.AccessList[i].Caption);
                    }
                    //Сохранение списка пользователей для справочника
                    SWriter.WriteLine(cMain.UserList.Length.ToString());
                    for (i = 0; i < cMain.UserList.Length; i++)
                    {
                        SWriter.WriteLine(cMain.UserList[i].ItemAction.DBExist.ToString());
                        SWriter.WriteLine(cMain.UserList[i].ItemAction.Changed.ToString());
                        SWriter.WriteLine(cMain.UserList[i].ItemAction.Deleted.ToString());
                        SWriter.WriteLine(cMain.UserList[i].ID.ToString());
                        SWriter.WriteLine(cMain.UserList[i].Caption);
                        SWriter.WriteLine(cMain.UserList[i].Password);
                        SWriter.WriteLine(cMain.UserList[i].AccessID.ToString());
                    }
                    //Сохранение списка тип групп отчетов для присоединений
                    SWriter.WriteLine(cMain.ReportGroupList.Length.ToString());
                    for (i = 0; i < cMain.ReportGroupList.Length; i++)
                    {
                        SWriter.WriteLine(cMain.ReportGroupList[i].ItemAction.DBExist.ToString());
                        SWriter.WriteLine(cMain.ReportGroupList[i].ItemAction.Changed.ToString());
                        SWriter.WriteLine(cMain.ReportGroupList[i].ItemAction.Deleted.ToString());
                        SWriter.WriteLine(cMain.ReportGroupList[i].ID.ToString());
                        SWriter.WriteLine(cMain.ReportGroupList[i].Caption);
                    }
                    //Сохранение списка территориальных объединений                    
                    SWriter.WriteLine(cMain.DC.Length.ToString());
                    for (i = 0; i < cMain.DC.Length; i++)
                    {
                        SWriter.WriteLine(cMain.DC[i].ItemAction.DBExist.ToString());
                        SWriter.WriteLine(cMain.DC[i].ItemAction.Changed.ToString());
                        SWriter.WriteLine(cMain.DC[i].ItemAction.Deleted.ToString());
                        SWriter.WriteLine(cMain.DC[i].ParentID.ToString());
                        SWriter.WriteLine(cMain.DC[i].ID.ToString());
                        SWriter.WriteLine(cMain.DC[i].Caption);
                    }
                    //Сохранение списка объектов                    
                    SWriter.WriteLine(cMain.Objects.Length.ToString());
                    for (i = 0; i < cMain.Objects.Length; i++)
                    {
                        SWriter.WriteLine(cMain.Objects[i].ItemAction.DBExist.ToString());
                        SWriter.WriteLine(cMain.Objects[i].ItemAction.Changed.ToString());
                        SWriter.WriteLine(cMain.Objects[i].ItemAction.Deleted.ToString());
                        SWriter.WriteLine(cMain.Objects[i].DCID.ToString());
                        SWriter.WriteLine(cMain.Objects[i].ID.ToString());
                        SWriter.WriteLine(cMain.Objects[i].Caption);
                        SWriter.WriteLine(cMain.Objects[i].ComputerAddress.ToString());
                        SWriter.WriteLine(cMain.Objects[i].CommChan.ToString());
                        SWriter.WriteLine(cMain.Objects[i].AddCommChan.ToString());
                        SWriter.WriteLine(cMain.Objects[i].CollectionState.ToString());
                        SWriter.WriteLine(cMain.Objects[i].CollectionStartDT.ToString());
                        //Расписание сбора                        
                        for (j = 0; j < cMain.Objects[i].Schedule.Length; j++)
                        {
                            SWriter.WriteLine(cMain.Objects[i].Schedule[j].ID.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Schedule[j].PeriodTypeID.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Schedule[j].PeriodCountID.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Schedule[j].CollectOn.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Schedule[j].CPeriodType.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Schedule[j].CPeriodCount.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Schedule[j].DPeriodType.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Schedule[j].DPeriodCount.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Schedule[j].HPeriodType.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Schedule[j].HPeriodCount.ToString());
                        }                       
                        SWriter.WriteLine(cMain.Objects[i].CodeNPATS);
                        SWriter.WriteLine(cMain.Objects[i].Code63002);
                        SWriter.WriteLine(cMain.Objects[i].IsExported.ToString());
                        SWriter.WriteLine(cMain.Objects[i].ExportDCID.ToString());
                        SWriter.WriteLine(cMain.Objects[i].ExportObjID.ToString());
                        //Сохранение списка устройств                        
                        SWriter.WriteLine(cMain.Objects[i].Device.Length.ToString());
                        for (j = 0; j < cMain.Objects[i].Device.Length; j++)
                        {
                            SWriter.WriteLine(cMain.Objects[i].Device[j].ItemAction.DBExist.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Device[j].ItemAction.Deleted.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Device[j].ItemAction.Changed.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Device[j].ID.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Device[j].DeviceID.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Device[j].NetAddress.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Device[j].Address.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Device[j].Identifier.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Device[j].SerialNumber.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Device[j].JournalLastDT.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Device[j].LastEventIdx.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Device[j].IsExported.ToString());
                            SWriter.WriteLine(cMain.Objects[i].Device[j].UserName);
                            SWriter.WriteLine(cMain.Objects[i].Device[j].UserPassword);
                            //Настройки протокола обмена                            
                            SWriter.WriteLine(cMain.Objects[i].Device[j].ProtocolSetting.Length.ToString());
                            SettingStr = "";
                            for (k = 0; k < cMain.Objects[i].Device[j].ProtocolSetting.Length; k++)
                                SettingStr = SettingStr + cMain.Objects[i].Device[j].ProtocolSetting[k].ToString() + "|";
                            SWriter.WriteLine(SettingStr);
                            //Сохранение списка коммутационного оборудования устройства
                            SWriter.WriteLine(cMain.Objects[i].Device[j].CommEquipment.Length.ToString());
                            for (k = 0; k < cMain.Objects[i].Device[j].CommEquipment.Length; k++)
                            {
                                SWriter.WriteLine(cMain.Objects[i].Device[j].CommEquipment[k].ItemAction.DBExist.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].CommEquipment[k].ItemAction.Changed.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].CommEquipment[k].ItemAction.Deleted.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].CommEquipment[k].ID.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].CommEquipment[k].ChannelNumber.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].CommEquipment[k].Caption);
                            }
                            //Сохранение списка присоединений устройства
                            SWriter.WriteLine(cMain.Objects[i].Device[j].Join.Length.ToString());
                            for (k = 0; k < cMain.Objects[i].Device[j].Join.Length; k++)
                            {
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ItemAction.DBExist.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ItemAction.Changed.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ItemAction.Deleted.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].DeviceID.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ID.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Index.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Caption);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].MeterNumber.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].CollectEnable.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].CoeffMultiply.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ConvertParam.ToString());
                                //Сохранение настроек каналов присоединения
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel.Length.ToString());
                                for (l = 0; l < cMain.Objects[i].Device[j].Join[k].Channel.Length; l++)
                                {
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel[l].ItemAction.DBExist.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel[l].ItemAction.Changed.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel[l].ItemAction.Deleted.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel[l].ID.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel[l].CollectEnable.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel[l].EnergyType.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel[l].MeterSerial.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel[l].MeterID.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel[l].ExportNPATSCode);
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel[l].ImportNPATSCode);
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel[l].Value63002Code);
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Channel[l].ASKPIdentifier);
                                }
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].KTT.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].KTN.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].KTTClass.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].KTNClass.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].IdlingLosts.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ShortCircuitLosts.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].TransformatorPower.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].MeterLostsValue.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].TTLostsValue.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].TNLostsValue.ToString());
                                //Линии электропередач (потери)                                
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ConnLineLosts.Length.ToString());
                                for (l = 0; l < cMain.Objects[i].Device[j].Join[k].ConnLineLosts.Length; l++)
                                {
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].ItemAction.DBExist.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].ItemAction.Changed.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].ItemAction.Deleted.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].ID.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].LineLength.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].Resistance.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].UNominal.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].CableLost.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].AirLost.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ConnLineLosts[l].CircuitsAmount.ToString());
                                }
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].MeterCodeHPATS);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ExportCodeHPATS);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ImportCodeHPATS);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].CollectPointAddress);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].MeterPlacement);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Comments);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].AbonentNumber);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].AgreementNumber);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].EvidenceMetod);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].BalanceBelonging);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].Director);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].GeneralPES);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].PhoneNumber);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].DTLastInspection.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].InSubscriberGroup.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].KPE.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].KPM.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].UTariffLevel.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].UTransformator.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].TransformatorLosts.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].LineLosts.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ITransformatorType);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].INominalFirstTT.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].INominalSecondTT.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].UTransformatorType);
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].UNominalFirstTT.ToString());
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].UNominalSecondTT.ToString());
                                //Группы отчетов
                                SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ReportGroup.Length.ToString());
                                for (l = 0; l < cMain.Objects[i].Device[j].Join[k].ReportGroup.Length; l++)
                                {
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ReportGroup[l].ItemAction.DBExist.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ReportGroup[l].ItemAction.Changed.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ReportGroup[l].ItemAction.Deleted.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ReportGroup[l].ID.ToString());
                                    SWriter.WriteLine(cMain.Objects[i].Device[j].Join[k].ReportGroup[l].RGType.ToString());
                                }
                            }
                        }
                    }
                    Result = true;
                }
                catch { Result = false; }
                SWriter.Close();
            }
            return Result;
        }

        private cFileBin() { }
    }
}
